//
//  KZCategoryEventsTableViewViewController.m
//  xiaorizi
//
//  Created by kun on 15/10/27.
//  Copyright © 2015年 origin. All rights reserved.
//

#import "KZCategoryEventsTableViewViewController.h"
//#import "CategoryEventModel.h"
#import "KZGlobalApi.h"
#import "KZDvdCell.h"
#import "dvdModel.h"
//#import "CategoryEventModel.h"
#import "KZCategoryEventCell.h"

#import "CategorySubEventModel.h"
#import "KZEventsViewController.h"

@interface KZCategoryEventsTableViewViewController ()


@end

@implementation KZCategoryEventsTableViewViewController



- (void)viewDidLoad {
  
    [self downloadDataPath];
    
    [super viewDidLoad];
    
    [self createBackItem];
    
    // Do any additional setup after loading the view.
}

- (void)downloadDataPath
{
    self.url = [KZGlobalApi categoryEventsUrl:_tagID];
    self.cachePath = [KZGlobalApi categoryEventsCachePath:_tagID];
    self.refreshType = FLRefreshTypeHeader;
    self.title = self.eventTitle;
}


-(void)createBackItem
{
    UIButton*button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:CGRectMake(0, 0, 40, 40)];
    [button setTitle:@"返回"forState:UIControlStateHighlighted];
    [button setTitle:@"返回"forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:@"back_1"] forState:UIControlStateNormal];
    
    UIBarButtonItem*bar = [[UIBarButtonItem alloc]initWithCustomView:button];
     self.navigationItem.leftBarButtonItem = bar;
    [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
}

-(void)back
{
    [self.navigationController popViewControllerAnimated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(NSString *)JsonModelPath
{
   // _tagID = 0;
    NSString* categoryStr = [NSString stringWithFormat:@"fenlei_%ld",_tagID];
    return [[NSBundle mainBundle]pathForResource:categoryStr ofType:@"json"];
}


- (id)createDataWithNode:(id)node
{
    CategorySubEventModel *model = [CategorySubEventModel initWithDic:node];
    return model;
}

-(NSArray *)createDataArray:(NSDictionary *)dic
{
    
    NSArray *arrayData = dic[@"list"];
    return arrayData;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 205;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
     KZCategoryEventCell *cell = [tableView dequeueReusableCellWithIdentifier:@"categoryEventCell" forIndexPath:indexPath];
    
        [cell setClickedImgToDetailView:^(UITableViewCell * cell, CategorySubEventModel * model) {
        
        UIStoryboard *discoverSB = [UIStoryboard storyboardWithName:@"KZEveryDvdTableViewController" bundle:nil];
        KZEventsViewController *discoverV = [discoverSB instantiateViewControllerWithIdentifier:@"KZEventsViewController"];
        discoverV.model = (EveryDayModel *)model;
        [self.navigationController pushViewController:discoverV animated:YES];
    }];
    
    CategorySubEventModel *model = self.data[indexPath.row];
    cell.model = model;
    
    return cell;
}






/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
